-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CastKind::Transmute
to MIR
#108442
Add CastKind::Transmute
to MIR
#108442
Conversation
Failed to set assignee to
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
fd0978a
to
c6bce48
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
To test it you could make the intrinsic mir pass convert the transmute function calls into an assignment of the new rvalue. That should allow removing all the intrinsic logic for transmute from the various backends |
c6bce48
to
6025fc9
Compare
tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
6025fc9
to
ff006d2
Compare
This comment has been minimized.
This comment has been minimized.
ff006d2
to
0905bad
Compare
The Miri subtree was changed cc @rust-lang/miri |
@oli-obk I see you resolved some comment threads here. Anything else you need from me before this is good to go? (If it's just that you need time to thoroughly review it that's totally ok!) |
yea, just needed to get to a PC to be able to review the diff properly and look at code that isn't nearby your changes. @bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e216300): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
Add `CastKind::Transmute` to MIR ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~ Includes lowering `transmute` calls to it, so it's used. Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
The regressions are small enough that I don't think this is worth investigating. @rustbot label: +perf-regression-triaged |
Thanks to the combination of rust-lang#108246 and rust-lang#108442 it could already remove identity transmutes. With this PR, it can also simplify them to `IntToInt` casts, `Discriminant` reads, or `Field` projections.
…jgillot Simplify transmutes in MIR InstCombine Thanks to the combination of rust-lang#108246 and rust-lang#108442 it could already remove identity transmutes. With this PR, it can also simplify them to `IntToInt` casts, `Discriminant` reads, or `Field` projections.
…i-obk Add `intrinsics::transmute_unchecked` This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`. Added to enable experimenting with the request in <rust-lang#106281 (comment)> and because the portable-simd folks might be interested for dependently-sized array-vector conversions. It also simplifies a couple places in `core`. See also rust-lang#108442 (comment), where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
Add `CastKind::Transmute` to MIR ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~ Includes lowering `transmute` calls to it, so it's used. Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
Add `intrinsics::transmute_unchecked` This takes a whole 3 lines in `compiler/` since it lowers to `CastKind::Transmute` in MIR *exactly* the same as the existing `intrinsics::transmute` does, it just doesn't have the fancy checking in `hir_typeck`. Added to enable experimenting with the request in <rust-lang/rust#106281 (comment)> and because the portable-simd folks might be interested for dependently-sized array-vector conversions. It also simplifies a couple places in `core`. See also rust-lang/rust#108442 (comment), where `CastKind::Transmute` was added having exactly these semantics before the lang meeting (which I wasn't in) independently expressed interest.
Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.Includes lowering
transmute
calls to it, so it's used.Zulip Conversation: https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610